<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <div>数量 <input id="goodsnum" /> </div>
        <div>价格 <input id="goodsprice" /> </div>
        <div>小计<span id="total"></span></div>
    </div>
</body>
<script>
    let goodsnumInput = document.getElementById("goodsnum");
    let goodspriceInput = document.getElementById("goodsprice");
    let totalSpan = document.getElementById("total");

    goodsnumInput.oninput = function () {
        totalSpan.innerHTML = goodsnumInput.value * goodspriceInput.value;
    }

    goodspriceInput.oninput  = function(){
        totalSpan.innerHTML = goodsnumInput.value * goodspriceInput.value;

    }


</script>

</html>